package iReportDemo;

import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;

import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;

public class JasperReportsViewer {

	public void viewReport(Map<String, Object> parameters)
	{
		JasperReportWrapper wrapper = new JasperReportWrapper();
		Connection connection =wrapper.connectToDB();
		JasperReport compiledReport = wrapper.compileJRXMLFile();
		JasperPrint jasperPrint = wrapper.fillReport(compiledReport, parameters, connection);
		wrapper.saveReportInPDF(jasperPrint, "Reports\\MyReports\\MyFirstReport.pdf");
		JasperViewer.viewReport(jasperPrint);
	}
}
